<template>
  <div class="search">
    <div class="wrapper">
      <input type="text" placeholder="秒杀好礼"/>
      <i class="iconfont icon-sousuo" id="init" ref="icon"></i>
      <div class="cancel" ref="cancel" v-tap="{methods:close}">取消</div>
    </div>
    <van-popup v-model="show" :style="{ height: '93%' }" position="bottom" :overlay="false">
      <p class="hot">热门搜索</p>
      <div class="tit">
          <a>制作盲盒</a>
          <a>新家卡</a>
          <a>秒杀好礼</a>
          <a>柜架</a>
          <a>美术馆系列</a>
      </div>
    </van-popup>
  </div>
</template>

<script>
export default {
  name: "search",
  data() {
    return {
      show: true
    };
  },
  methods: {
    
    close() {
      this.$refs.cancel.style.display = "none";
      this.$refs.icon.setAttribute("id", "init");
      this.show = false;
      this.$router.go(-1);
    }
  },
  mounted(){
    this.$refs.icon.setAttribute("id", "change");
    document.getElementsByTagName("input")[0].focus();
    this.$refs.cancel.style.display = "block";
    document.getElementsByTagName("input")[0].onchange = ()=>{
      this.$router.push("/searchcontent?pname="+document.getElementsByTagName("input")[0].value);
    }
  }
};
</script>

<style scoped>
.search {
  padding: 5px 10px;
}
.wrapper {
  height: 75px;
  border-bottom: solid 1px #000;
  line-height: 75px;
  position: relative;
}
.wrapper input {
  height: 50px;
  width: 85%;
  border: 0;
  margin-left: 20px;
}
.wrapper #init {
  font-size: 36px;
  line-height: 75px;
  float: right;
  margin-right: 20px;
}
.wrapper #change {
  font-size: 28px;
  line-height: 75px;
  float: left;
  margin-left: 10px;
  font-weight: bold;
  color: #615f5f;
}
.wrapper .cancel {
  font-size: 24px;
  position: absolute;
  right: 20px;
  top: 3px;
  display: none;
}

.hot{
    margin-left: 20px;
    font-size: 24px;
}
.tit{
    padding: 10px;
}
.tit a{
    padding: 10px;
    background-color: #eee;
    margin: 10px;
}
</style>

